<template>
<div>
  <div class="clearfix deal_avatar" style="margin-bottom: 1rem;">
    <img class="left" :src="dealInfor.usrPic" />
    <span class="left" style="width: 10rem;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">{{dealInfor.usrName}}</span>
    <span class="right">{{dealInfor.txnDate | endtimeStamp}}</span>
  </div>
  <div class="whiteBg">
    <div class="deal_list_info">
      <div class="couponDiv">
        <coupon-denomination :item="dealInfor"></coupon-denomination>
      </div>
      <div class="deal_i_con">
        <p class="couponName">
          <span class="right">
						<span class="color-seec4">{{dealInfor.yunCur}}</span>
          <span>芸券</span>
          </span>
          <span class="bord_tit">{{dealInfor.couponName}}</span>
        </p>
        <p class="couponType">
          <span class="right">×{{dealInfor.sellNum}}(张)</span>
          <span v-if="dealInfor.couponType==='voucher'">{{dealInfor.denomination}}抵用券（满{{dealInfor.restricted}}使用）</span>
          <!--<span v-if="dealInfor.couponType==='rebate'" class="denomination">全场{{dealInfor.denomination | denomination}}折 (<span  class="scpoe">{{scpoe(dealInfor.scpoe)}}</span>)</span>-->
          <span v-if="dealInfor.couponType==='rebate'" class="denomination">全场{{dealInfor.denomination | denomination}}折 </span>
          <span v-if="dealInfor.couponType==='cash'">¥{{dealInfor.denomination}}元代金券</span>

        </p>
        <p v-if="dealInfor.eventType==1"><span class="right">{{dealInfor.fee}}芸券</span>手续费</p>
        <p><span class="right">{{dealInfor.eventType==1?'收入：'+(dealInfor.yunCur*dealInfor.sellNum-dealInfor.fee):'支出：'+dealInfor.yunCur*dealInfor.sellNum}}芸券</span></p>
      </div>
    </div>
  </div>
  <div class="whiteBg shop_info_hd mgt10">
    <div class="shop_consume shop_deal">
      <span class="left">代金券发放商家</span>
      <a @click="$router.push({name: 'merchDetail',query: {mchtId: dealInfor.mchtId}})" class="right">查看商家<i class="iconfont icon-right right"></i></a>
    </div>
    <div class="shop_info" style="box-sizing:content-box;">
      <img class="left" :src="dealInfor.mchtLogUrl">
      <div class="clearfix shop_name">
        <span class="left">{{dealInfor.mchtName}}</span>
        <span class="right">¥{{dealInfor.mchtPer}}/人</span>
      </div>
      <div class="clearfix shop_type">
        <span class="left">{{dealInfor.mchtType}}</span>
        <span class="right">{{dealInfor.mchtArea}}</span>
      </div>
    </div>

  </div>
  <div class="whiteBg order_detail">
    <h3>订单明细</h3>
    <!-- <p><span class="left">订单编号</span><span class="right">7666666666</span></p> -->
    <p><span class="left">购券时间</span><span class="right">{{dealInfor.txnDate | endtimeStamp}}</span></p>
    <p><span class="left">流水号</span><span class="right">{{dealInfor.seqNo}}</span></p>
    <!-- <p><span class="left">使用日期</span><span class="right">{{dealInfor.validatyBegin | Time}}-{{dealInfor.validatyEnd | Time}}</span></p> -->
  </div>
</div>
</template>
<script>
import * as types from '../../vuex/types.js'
import * as types1 from '../../vuex/appendType'
import {
  mapState
} from 'vuex'
export default {
  data: () => ({
    dealInfor: {}
  }),
  methods: {
    scpoe: function(value) {
      let type =  value.substring(0, 1)
      let newVal
      // I: 包括  T: 不包括
      if (type === 'I') {
        newVal = `包括${value.substring(1,value.length-1)}`
      } else {
        newVal = `不包括${value.substring(1,value.length-1)}`
      }
      return newVal
    },
  },
  beforeRouteLeave(to, from, next) {

    next()
  },
  created: function() {
    var that = this;
    this.$store.dispatch("dealDetail", {
      data: {
        seqNo: that.$route.params.seqNo,
        usrId: that.userInfo.usrId
      },
      method: 'post'
    }).then(function(rep) {
			rep.content.type = rep.content.couponType
      that.dealInfor = rep.content
    }).catch(function(rep) {
      console.log(rep);
    })
  },
  computed: {
    ...mapState({
      dealInfo: state => state.find.dealInfo,
      userInfo: state => state.user.userInfo
    })
  },
	filters: {
		denomination: function(value) {
			let newVal = value.toString().split('').join('.')
			return newVal
		},
		Time: function(value) {
			if (value) {
				let timeVal = `${value.substring(0, 4)}.${value.substring(4, 6)}.${value.substring(6, 8)}`
				return timeVal;
			}
		}
	}
}
</script>
<style>

</style>
